<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户信息 - 空明物联网服务平台</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/static/css/base.css" />
</head>


<body>
    <div class="container-fluid">
        <br />


        <div>
            <ul class="nav nav-tabs" role="tablist" id="myTabs">
                <li role="presentation" class="active"><a href="#userinfo" aria-controls="userinfo" role="tab"
                        data-toggle="tab">个人信息</a></li>
                <!-- <li role="presentation"><a href="#config" aria-controls="config" role="tab" data-toggle="tab">配置项</a>
                </li> -->

            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="userinfo">
                    <br />
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <div class="form-inline">
                                        <label class="col-sm-2 control-label">用户邮箱</label>
                                        <div class="col-sm-10">
                                            
                                            <input type="text" class="form-control" id="email" disabled="disabled" />
                                            <div id="email_status" style="display:inline" hidden>
                                                <span class="label label-default">未验证</span> 
                                                <button type="button" id="btn-send-email" class="btn btn-default">发送激活邮件</button>
                                            </div>
                     
                                        </div>
                                    </div>
                                </div>
                                <!-- <div class="form-group">
                                    <div class="form-inline">
                                        <label class="col-sm-2 control-label">手机号</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="tel"> 
                                            <button type="button"  class="btn btn-default">修改</button>
                                        </div>
                                    </div>
                                </div> -->

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">用户名</label>
                                    <div class="col-sm-10">
                                        <span id="name"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">注册时间</label>
                                    <div class="col-sm-10">
                                        <span id="reg_time"></span>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>


                </div>
                <!-- <div role="tabpanel" class="tab-pane" id="config">

                </div> -->
            </div>

        </div>

    </div>
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>

    <script src="/static/js/base.js?version=1.0.0"></script>
    <script>
        $('#myTabs a').click(function (e) {
            e.preventDefault()
            $(this).tab('show')
        })


        // 发送激活邮件
        $("#btn-send-email").click(function (){
            new AjaxRequest({
                type: "post",
                url: getServiceURL('sendverifyemail'),
                param: {},
                callBack: function (res) {
                    if (res.code == 0) {
                        alert("激活邮件发送成功!");
                    } else {
                        alert(res.msg);
                    }
                    console.log(res);
                }
            });
       
        });


        function getUserInfo() {
            new AjaxRequest({
                type: "get",
                url: getServiceURL('userinfo'),
                param: {},
                callBack: function (res) {
                    if (res.code == 0) {
                        var user = res.data.user;

                        if (user.email_status == 0){
                            $("#email_status").hide();
                        }else{
                            $("#email_status").show();
                        }

                        $("#userinfo #email").val(user.email);
                        $("#userinfo #tel").html(user.tel);
                        $("#userinfo #name").html(user.name);
                        $("#userinfo #reg_time").html(user.reg_time);
                        
                    } else {
                        alert(res.msg);
                    }
                    console.log(res);
                }
            });
        }

        getUserInfo();
        $(document).ready(function () {

        });
    </script>
</body>

</html>